<template>
<div class="">
  <router-link to="/" class="weui_btn" style="border-radius: 0;background-color:#337ab7">1</router-link>
  <router-link to="/" class="weui_btn weui_btn_plain_default">Home</router-link>
  <div class="" style="text-align: center;">
    <div class="qrcode">
      <div id="qrcode"></div>
      <br>
      <!-- <div class="">此二维码带有您的推广标识!</div> -->
      <p>111</p>
      <p>333</p>
      <p>2222</p>
    </div>
  </div>
  <div class="" v-for="i of varInfo">
    {{i.fields.name}} {{i.fields.author}}
  </div>
</div>
</template>

<script>
import data from '../data/data.json';
import simRecdata from '../data/simRecdata.json';
// import QRCode from '../plugin/qrcode';
// import Config from '../config/Config';
// import User from '../service/User';
// import Canvas from '../class/Canvas.js';
// import lesson2 from '../class/lesson3.js';
import {
  getBook1
} from '../api/api';
import {
  A,
  test,
  Parent
} from '../class/lesson17'

export default {
  data() {
    return {
      items: data.items,
      sentenceList: simRecdata.sentenceList,
      varInfo: []
    };
  },
  /**
   * created
   */
  created() {
    // getBook1()
    //   .then((response) => {
    //     // console.log(response.data)
    //     this.varInfo = response.data
    //   })
  },
  /**
   * mounted
   */
  beforeMount() {},
  mounted() {
    // this.useqrcode();
    function last() {
      // // 类
      // console.log(A);
      // console.log(test());
      // console.log('class', Parent);
      // Parent.say()
      // let vParent = new Parent();
      // console.log('object', vParent);
      // console.log(vParent.name);
      // vParent.tell()
      // Parent.say()

      // let ajax = function() {
      //   console.log('执行2');
      // return new Promise(function(resolve, reject) {
      //   setTimeout(() => {
      //     resolve()
      //   }, 1000)
      // })
      // };

      let ajax = () => {
        console.log('111');
        return new Promise((resolve, reject) =>
          setTimeout(() => {
            resolve()
          }, 2000)
        )
      }
      // let ajax = () =>
      // console.log('执行2');
      // new Promise((resolve, reject) =>
      //   setTimeout(() => {
      //     resolve()
      //   }, 2000)
      // )
      ajax().then(function() {
        console.log('222');
      })
    }
    last()
  },
  methods: {
    useqrcode() {
      // new QRCode(window.document.getElementById('qrcode'), {
      //   text: `a`,
      //   width: 200,
      //   height: 200,
      //   colorDark: '#000000',
      //   colorLight: '#ffffff'
      //   // correctLevel : QRCode.CorrectLevel.H
      // });
    },
    getQueryString(name) {
      console.log('1111');
      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
      var r = window.location.search.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    }
  }
}
</script>

<style lang="scss" scoped>
.qrcode {
    text-align: center;
    margin-top: 3rem;
    div {
        color: #888;
        font-size: 12px;
    }
    #qrcode {
        img {
            margin: 0 auto;
        }
    }
}
</style>
